home *** CD-ROM | disk | FTP | other *** search
- Path: news.halcyon.com!usenet
- From: normanb@halcyon.com (Norm Bryar)
- Newsgroups: comp.lang.c++
- Subject: Re: [Q] namespace #1
- Date: Tue, 05 Mar 1996 15:57:49 GMT
- Organization: Northwest Nexus Inc.
- Message-ID: <4hho8l$aec@news.halcyon.com>
- References: <4hf81b$aov@crl.crl.com>
- NNTP-Posting-Host: blv-pm3-ip8.halcyon.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- dbridges@crl.com (Dick Bridges) wrote:
-
- >#include <iostream.h>
-
- >namespace foo
- >{
- > int Value = 43;
- >};
-
- >void main()
- >{
- > int Value = 65;
- > using namespace foo;
- > cout << Value << endl;
- >}
-
- >// QUESTIONS:
- >// 1) Is this a valid program
- >// 2) If so what is the expected output, if not what is the error
- >// 3) What would be the result of using a using declaration instead
- >// instead of a using directive
- >//
- >// NOTES:
- >// 1) The Microsoft VC++ 4.0 compiler complains that Value is an
- >// ambiguous symbol. Is this correct?
-
- You can't replace namespaces with "using," you can ony add additional
- namespaces. Main defined Value, foo defined Value, and your using the
- namespace of both in the cout <<... statement.
-
- I've had similar problems in a program mixing third-party and
- home-grown components: two headers defined classes with the same name
- and I had to include both in one module. Namespaces did not allow me
- to switch which implementation CXxxx really meant.
-
- --Norm
-
-